<?php

namespace App\Http\Controllers\Wechat;

use App\Http\Controllers\Controller;
use App\Http\Requests\Wechat\WechatRequest as Request;

class WechatController extends Controller
{
    //微信认证方法
    public function getServer()
    {
        $wechat = app('wechat');
        $server = $wechat->server;
        // 转发收到的消息给客服
        $server->setMessageHandler(function ($message) {
            return new \EasyWeChat\Message\Transfer();
        });
        //这一句是对微信进行了验证
        return $server->serve();
    }
    //认证成功后返回信息
    public function postServer(Request $req)
    {
        return $req->service();
    }
}
